# pages/login_page.py
from selenium.webdriver.common.by import By
from pages.Base_page import BasePage

class LoginPage(BasePage):
    # —— 定位符（稳定优先：id > data-test > 语义文本 > 其他）——
    username = (By.ID, "user-name")
    password = (By.ID, "password")
    login_btn = (By.ID, "login-button")

    def open_login(self):
        """进入登录页。"""
        self.open("https://www.saucedemo.com/")

    def login(self, username="standard_user", password="secret_sauce"):
        """执行登录动作（把“怎么输/点”封装起来）。"""
        self.type(self.username, username)
        self.type(self.password, password)
        self.click(self.login_btn)